var app = new Vue({
	el:"#app",
	data:{
		lucks:[],
		pageNum:1,
		isBottom:false,
		isExcute:false,
	},
	methods:{
		list:function(){
			var t = this;
			if (this.isBottom) return !1;
			wx.showLoading({
				title: "加载中",
				mask: !0
			}), this.$http.post(baseUrl + "luck/listByUser", {
				currentPage: this.pageNum,
				pageSize: 10
			}).then(function(a) {
				var s = a.data;
				wx.hideLoading();
				if (!s.success) return wx.hideLoading(), wx.showToast({
					title: s.description,
					icon: "none",
					duration: 2e3,
					mask: !0
				}), !1;
				if (s.data.length > 0 && 1 == t.pageNum)t.lucks = s.data;
				else if (s.data.length > 0 && t.pageNum > 1) {
					s.data.forEach(function(e) {
						t.lucks.push(e);
					})
				} else if (0 == s.data.length && t.pageNum > 1) return wx.showToast({
					title: "已经到最底下了",
					icon: "none",
					duration: 1e3,
					mask: !0
				}), t.isBottom = !0, !1;
			}).catch(function(t) {
				wx.hideLoading(), console.log(t), wx.showToast({
					title: "网络错误，请检查网络",
					icon: "none",
					duration: 2e3,
					mask: !0
				});
			});
			t.isExcute = false;
		},
		handleScroll: function() {
			// 防止重复
			if (this.isExcute) {
				return;
			}
			if (this.isBottom) {
				return;
			}
			var flag = srollEvent.isReachBottom();
			if (!flag) {
				return;
			}
			this.isExcute = true;
			this.pageNum++;
			this.list();
		},
	},
	mounted: function() {
		window.addEventListener("scroll", this.handleScroll, {
			passive: false
		});
	},
	created:function(){
		this.list();
	}
	
});